package com.chen.mapper;

import com.chen.popj.entity.Contest;
import com.chen.popj.entity.ContestCodeSubmit;
import com.chen.popj.entity.ContestProblem;
import com.chen.popj.entity.JudgeCase;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ContestMapper {

    /**
     * 根据比赛id和题目id获取比赛题目信息
     *
     * @param problemId
     * @param contestId
     * @return
     */
    @Select("select * from contest_problem where problem_id=#{problemId} and contest_id=#{contestId}")
    ContestProblem getContestProblemDetails(Integer problemId, Integer contestId);

    /**
     * 创建比赛
     *
     * @param contest
     * @return
     */
    Integer createContest(Contest contest);

    /**
     * 根据比赛id获取比赛信息
     *
     * @param contestId
     * @return
     */
    @Select("select * from contest where id =#{contestId} ")
    Contest getContestInfo(Integer contestId);

    /**
     * 创建比赛
     *
     * @param contestProblemList
     */
    void saveProblem(List<ContestProblem> contestProblemList);

    /**
     * 根据比赛id获取比赛题目
     *
     * @param contestId
     * @return
     */
    @Select("select problem_id from contest_problem where contest_id=#{contestId};")
    List<Integer> getContestProblem(Integer contestId);

    /**
     * 根据比赛id和用户id获取用户比赛时的代码提交记录
     *
     * @param contestId
     * @param userId
     * @return
     */
    @Select("select * from contest_code_submit where contest_id = #{contestId} and user_id =#{userId} ")
    List<ContestCodeSubmit> getSubmissionRecord(Integer contestId, Integer userId);

    /**
     * 根据比赛id和屏幕id修改比赛题目信息
     *
     * @param contestProblem
     */
    void updateByContestIdAndProblemId(ContestProblem contestProblem);
}
